package Class_03_01;

public class homework3 {
    public static void main(String[] args) {
        //输出100以内的所有素数，每行5个
        int num1 = 100;
        int flag = 0;
        for (int i = 2; i <= num1; i++)
        {
            if(prime(i))
            {
                System.out.printf("%d ",i);
                flag++;
            }
            if(flag == 5)
            {
                System.out.println();
                flag = 0;
            }
        }
    }
    public static boolean prime(int num)
    {
        double k = Math.sqrt((double)num);
        if(num == 2)
        {
            return true;
        }
        for (int i = 2; i <= k; i++)
        {
            if(num % i ==0)
            {
                return false;
            }
        }
        return true;
    }
}
